const HtmlWebpackPlugin = require("html-webpack-plugin");
const { resolve } = require("path");

module.exports = {
  entry: "./src/index.js",
  output: {
    path: resolve(__dirname, "dist"),
    filename: "monitor.js",
  },
  mode: "development",
  devServer: {
    onBeforeSetupMiddleware(router) {
      router.app.get("/success", function (req, res) {
        res.json({ id: 1 });
      });
      router.app.post("/error", function (req, res) {
        res.sendStatus(500);
      });
    },
    open: true,
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./src/index.html",
      inject: "head",
    }),
  ],
};
